package com.sfzd5.aiclassroom;

import com.sfzd5.UI.HomeWorkManager;
import org.cef.CefApp;
import org.cef.CefSettings;
import org.cef.OS;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;

public class Main {

    public static void main(String[] args) throws InterruptedException {

        CefSettings settings = new CefSettings();
        settings.windowless_rendering_enabled = OS.isLinux();
        settings.persist_session_cookies = true;

        File file = new File("cache");
        if (!file.exists())
            file.mkdir();
        settings.cache_path = "cache";

        CefApp.getInstance(settings);

        runmain();
    }

    static void runmain(){

        JFrame frame = new JFrame("教学管理系统");

        frame.addWindowListener(new WindowListener() {
            @Override
            public void windowOpened(WindowEvent e) {

            }

            @Override
            public void windowClosing(WindowEvent e) {
                CefApp.getInstance().dispose();
            }

            @Override
            public void windowClosed(WindowEvent e) {

            }

            @Override
            public void windowIconified(WindowEvent e) {

            }

            @Override
            public void windowDeiconified(WindowEvent e) {

            }

            @Override
            public void windowActivated(WindowEvent e) {

            }

            @Override
            public void windowDeactivated(WindowEvent e) {

            }
        });

        frame.setLocationRelativeTo(null);
        HomeWorkManager teacherForm = new HomeWorkManager();
        frame.setContentPane(teacherForm.mPanel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle bounds = new Rectangle(screenSize);
        frame.setBounds(bounds);
        frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

        frame.setVisible(true);


    }

}
